; TODO refactory
; reduce useless variables
GAME_INITIAL:
	LDA VAR_DINO_STATUS
	CMP #DINO_STATUS_JUMPING
	BNE .GAME_LOGIC_END
	LDA #GAME_STATUS_TRANSITION_1
	STA VAR_GAME_STATUS
	RTS


; dino first jump
GAME_TRANSITION_1
	LDA VAR_DINO_STATUS
	CMP #DINO_STATUS_STAND
	BNE .GAME_LOGIC_END
	LDA #GAME_STATUS_TRANSITION_2
	STA VAR_GAME_STATUS
	LDA #$00
	STA VAR_TRANSITION_COLUMN_ID
	RTS


; draw horizon line
GAME_TRANSITION_2
	LDA VAR_TRANSITION_COLUMN_ID
	ADC #TRANSITION_COLUMN_OFFSET
	CMP #$80
	BNE GAME_TRANSITION_DRAW
	LDA #GAME_STATUS_RUN
	STA VAR_GAME_STATUS
	JMP .GAME_LOGIC_END
	RTS


GAME_TRANSITION_DRAW
	LDA #$22
	STA PPU_ADDR
	LDA VAR_TRANSITION_COLUMN_ID
	ADC #$01
	STA VAR_TRANSITION_COLUMN_ID
	TAY
	ADC #TRANSITION_COLUMN_OFFSET
	STA PPU_ADDR
	LDA BIN_HORIZON_LINE,y
	STA PPU_DATA

	MACRO_DINO_ADD_X $01
	RTS


GAME_RUNNING:
	; screen rendering
	JSR DRAW_BACKGROUND
	JSR SCROLLING_BACKGROUND
	RTS


GAME_OVER:
	LDA VAR_LAST_A_0
	CMP #$01
	BNE .GAME_LOGIC_END
	JSR RESET


.GAME_LOGIC_END:
	RTS
